package hn.cch.performance.appender;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;

import java.util.Map;

import static hn.cch.performance.constant.MyConstant.TRACE_ID;

public class CustomAppender extends AppenderBase<ILoggingEvent> {
    @Override
    protected void append(ILoggingEvent iLoggingEvent) {
        Map<String, String> mdcPropertyMap = iLoggingEvent.getMDCPropertyMap();
        if (mdcPropertyMap.containsKey(TRACE_ID)) {
            System.out.println("ID:" + mdcPropertyMap.get(TRACE_ID) + ":" + iLoggingEvent.getFormattedMessage());
        }
    }
}
